package com.hksj.am.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hksj.am.query.AmmoniaDeviceHistoryQuery;
import com.hksj.am.query.AmmoniaDeviceQuery;
import com.hksj.am.service.AmmoniaDeviceService;
import com.hksj.am.vo.AmmoniaDeviceHistoryVO;
import com.hksj.am.vo.AmmoniaDeviceVO;
import com.hksj.common.core.model.Rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "氨气监测——设备列表")
@RestController
@RequestMapping("/api/am/device")
public class AmmoniaDeviceController {

    @Autowired
    private AmmoniaDeviceService ammoniaDeviceService;

    @ApiOperation(value = "分页查询氨气设备列表",response = AmmoniaDeviceVO.class)
    @PostMapping("/queryAmmoniaDeviceByPaging")
    public Rest<IPage<AmmoniaDeviceVO>> queryAmmoniaDeviceByPaging(@RequestBody AmmoniaDeviceQuery query){
        IPage<AmmoniaDeviceVO> page = ammoniaDeviceService.queryAmmoniaDeviceByPaging(query);
        return Rest.ok(page);
    }

    @ApiOperation(value = "查询氨气设备氨气浓度趋势折线图")
    @PostMapping("/queryAmmoniaDeviceHistoryList")
    public Rest<List<AmmoniaDeviceHistoryVO>> queryAmmoniaDeviceHistoryList(@RequestBody AmmoniaDeviceHistoryQuery query){
        return Rest.ok(ammoniaDeviceService.queryAmmoniaDeviceHistoryList(query));
    }

    @ApiOperation(value = "分页查询氨气设备氨气浓度趋势",response = AmmoniaDeviceHistoryVO.class)
    @PostMapping("/queryAmmoniaDeviceHistoryByPaging")
    public Rest<IPage<AmmoniaDeviceHistoryVO>> queryAmmoniaDeviceHistoryByPaging(@RequestBody AmmoniaDeviceHistoryQuery query){
        return Rest.ok(ammoniaDeviceService.queryAmmoniaDeviceHistoryByPaging(query));
    }

    @ApiOperation(value = "导出氨气设备氨气浓度趋势")
    @PostMapping("/exportAmmoniaDeviceHistory")
    public void exportAmmoniaDeviceHistory(@RequestBody AmmoniaDeviceHistoryQuery query, HttpServletResponse response){
        ammoniaDeviceService.exportAmmoniaDeviceHistory(query, response);
    }

}
